<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>消息中心</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="@{/layuiadmin/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/layuiadmin/style/admin.css}" media="all">
    <script type="text/javascript" th:src="@{/static/layui/jquery.min.js}"></script>
    <script th:inline="javascript">
        var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];
        var userid = [[${session.userid}]];
    </script>
</head>
<body style="background-color: white;">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="animated fadeIn">
                <table class="layui-hide" lay-skin="line" id="collect" lay-filter="test" style="width:100%"></table>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" th:src="@{/static/layui/layui.js}"></script>
<script>
    layui.use(['form', 'slider'], function () {
        let form = layui.form
            , layer = layui.layer;
    });
    layui.use(['form', 'element', 'util', 'carousel', 'laypage', 'layer','table'], function () {
        var table = layui.table;
        table.render({
            elem: '#collect'
            , url: basePath+'/notices/queryall'
            ,cellMinWidth: 80
            , page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip']
                , groups: 3
                , limits: [20, 50, 100]
                , limit: 20
            }, cols:
                [
                    [
                        {field: 'isread', title: '状态',width: 60,  align:'center'}
                        , {field: 'tpname', title: '类型',width: 120,  align:'center'}
                        , {field: 'whys', title: '内容', align:'center'}
                        , {field: 'nttime', title: '时间', width: 160, align:'center'}
                    ]
                ]
            ,height: 500
            , done: function (res, curr, count) {
                $("[data-field='isread']").children().each(function () {
                    if($(this).text() == '状态') {
                        $(this).text("状态")
                    }else if($(this).text() == 0){
                        $(this).html("<span class=\"layui-badge-dot\"></span>")
                    }else if($(this).text() == 1){
                        $(this).html("<span class=\"layui-badge-dot layui-bg-gray\"></span>")
                    }
                });
                $("[data-field='whys']").children().each(function () {
                    $(this).html($(this).html())
                });
            }
        });
        //监听行工具事件
        table.on('tool(test)', function (obj) {

        });
        //监听行单击事件（双击事件为：rowDouble）
        table.on('row(test)', function(obj){
            var data = obj.data;
            $.ajax({
                url: basePath + "/notices/look/"+data.id,
                data: "",
                contentType: "application/json;charset=UTF-8", //发送数据的格式
                type: "put",
                dataType: "json", //回调
                success: function (data) {
                    window.location.reload();
                }
            });
        });
    });
</script>
</html>